Skip to content

fix: replace strcpy with g_strlcpy for module_name in sidebar#1338

Merged
karlkleinpaste merged 1 commit into
crosswire:masterfrom
hyder365:fix/sidebar-strcpy-overflow
Jun 30, 2026
Merged

fix: replace strcpy with g_strlcpy for module_name in sidebar#1338
karlkleinpaste merged 1 commit into
crosswire:masterfrom
hyder365:fix/sidebar-strcpy-overflow

Conversation

@hyder365

Copy link
Copy Markdown
Contributor

main_display_verse_list_in_sidebar() in src/main/sidebar.cc copies module_name into two fixed 80-byte buffers (settings.sb_search_mod[80] and sidebar.mod_name[80]) using strcpy() with no length check.

When BibleSync navigation takes the indirect path (unknown module name, multi-verse reference, or user preference for indirect navigation), the bible field from the UDP packet is passed directly as module_name at biblesync_glue.cc:184. A bible field exceeding 80 bytes overflows both global buffers, corrupting adjacent fields in the SETTINGS and SIDEBAR structs.

The fix replaces both strcpy() calls with g_strlcpy(), which always null-terminates and never writes more than the specified buffer size.

main_display_verse_list_in_sidebar() copies module_name into two
fixed 80-byte buffers (settings.sb_search_mod[80] and
sidebar.mod_name[80]) using strcpy() with no bounds check.

When BibleSync navigation takes the indirect path (unknown module,
multi-ref, or user preference), the bible field from the UDP packet
is passed directly as module_name at biblesync_glue.cc:184.  A bible
field exceeding 80 bytes overflows both global buffers.

Replace strcpy with g_strlcpy, which always null-terminates and never
writes more than the specified buffer size.
@karlkleinpaste karlkleinpaste merged commit 83af400 into crosswire:master Jun 30, 2026
7 checks passed
@karlkleinpaste

Copy link
Copy Markdown
Contributor

I am perversely impressed by the wide variety of such things you're finding to fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants